package com.xm.pojo;

import java.util.HashMap;
import java.util.Map;

public class R {
//
    private Integer errorCode;
    private String errorMsg;
    private Boolean success;
    private Map<String,Object> data = new HashMap<String,Object>();

    private R(){

    }

    public static R OK(){
        R r=new R(ResultCode.SUCCESS,"成功",true);
        return r;
    }

    public static R ERROR(){
        R r=new R(ResultCode.ERROR,"失败",false);
        return r;
    }


    public R errorMsg(String errorMsg){
        this.setErrorMsg(errorMsg);
        return  this;
    }

    public R errorCode(Integer errorCode){
        this.setErrorCode(errorCode);
        return  this;
    }

    public R success(Boolean success){
        this.setSuccess(success);
        return  this;
    }

    public R data(Map map){
        this.setData(map);
        return  this;
    }

    public R data(String key,Object values){
        this.data.put(key,values);
        return  this;
    }



    public R(Integer errorCode, String errorMsg, Boolean success) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.success = success;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public Integer getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public Boolean getSuccess() {
        return success;
    }

    public Map<String, Object> getData() {
        return data;
    }


}
